package org.ns.summer.classpath.scan;

import java.lang.annotation.Annotation;
import java.util.Set;

import org.ns.summer.classpath.classreader.entity.ClassInfo;
import org.ns.summer.classpath.classreader.entity.ClassInfoUtils;

/**
 *
 * @author 张星宇
 *
 * @email m.vip@qq.com
 */
public class ScanClassInfo {

	private String className;
	private String superName; // 父类名称
	private Set<String> interfaces; // 接口名称集合
	private Set<String> annotations; // 类上拥有的注解
	private boolean interfaceType;
	private boolean abstractType;
	public ScanClassInfo(ClassInfo classInfo) {
		super();
		this.className = classInfo.getClassName();
		this.superName = classInfo.getSuperName();
		this.interfaces = ClassInfoUtils.toHashSet(classInfo.getInterfaces());
		this.annotations = ClassInfoUtils.toHashSet(classInfo.getAnnotations());
		this.interfaceType = classInfo.isInterface();
		this.abstractType = classInfo.isAbstract();
	}

	public String getClassName() {
		return className;
	}

	public String getSuperName() {
		return superName;
	}

	public Set<String> getInterfaces() {
		return interfaces;
	}

	public Set<String> getAnnotations() {
		return annotations;
	}

	public boolean isAnnotation(Class<? extends Annotation> annType) {
		return isAnnotation(annType.getName());
	}

	public boolean isAnnotation(String annTypeName) {
		return this.annotations.contains(annTypeName);
	}

	public boolean isInterface(Class<?> interfaceType) {
		return this.interfaces.contains(interfaceType.getName());
	}

	public boolean isInterface(String interfaceName) {
		return this.interfaces.contains(interfaceName);
	}

	public boolean isAbstractType() {
		return abstractType;
	}
	public boolean isInterfaceType() {
		return interfaceType;
	}
}
